<?php 
	echo "
	<div class='lp1 pad15' style = 'background: none; '>
		<div class='bpad15'>
			<div class = 'pageHeading'>
				".$this->data['chat']['name']."<br />
				<span class = 'pageSubHeading'>".Language::Get('by')." ".$this->data['author']['first_name']." ".$this->data['author']['last_name']."<span>
			</div>
			<div id = 'chatRoomContainer' style = 'height: 290px; overflow-y: scroll; '>";

	//messages
	foreach ($this->data['messages'] as $message)
	{
		echo HtmlsHelper::ChatMessage($message['client_first_name'], $message['client_last_name'], $message['text'], $message['datetime']);
	}

	echo "	</div>";
	echo '	<form action = "#" method = "POST" id = "messageForm" style = "margin-bottom: 0px; padding-bottom: 0px; " onsubmit = "'.jQuery::Post('/chatmessages/send/', 'messageForm', 'OnMessageSent').' return false; ">';
				XHTML::InputText('message', '', array('id' => 'messageField', 'style' => "width: 470px; "));
				XHTML::InputSubmit('send', Language::Get('Submit'), array('style' => ""));
	echo "		<!--<div id='btnSend' style = 'width: 60px; height: 30px; '>".Language::Get('Submit', '')."</div>-->
			</form>
		</div>
	</div>";
	
	XHTML::Script('text/javascript', "
	
		//after chat message sent
		function OnMessageSent(data)
		{
			$('#messageField').val('');
			$('#chatRoomContainer').prepend(data);
			return true;
		}
		
		//after messages list updated
		function OnMessagesUpdated(data)
		{
			$('#chatRoomContainer').prepend(data);
			return true;
		}	

		//checks for new messages
		window.setInterval(function()
		{
    		$.post('/chatmessages/getnewmessages/', '', OnMessagesUpdated);
		}, 1000);
		
	");
?>

<script type="text/javascript">
	$('#btnSend').dqButton({type:5, action:"", clickType:'js', live: true});	
	$('.dq-input-text').dqInput();
</script>